import { Db } from "../constant";
import moment from 'moment';

const INIT = {
    dateType: {
        value: 1,
        rangeDisabled: false,
        unitDisabled: true,
    },
    dateRange: [moment(new Date()).add(-1, 'minutes'), moment(new Date())],
    dateUnit: 'm'
};

export default function reducer(state = INIT, { type, data }) {
    if (Db.DATETYPE === type) state = {...state, dateType: data};
    if (Db.DATEUNIT === type) state = {...state, dateUnit: data};
    return state;
}